const Queue = require('./queue')

function fibonacci(n) {
  if (n < 2) return n
  const queue = new Queue()
  queue.enqueue(1)
  queue.enqueue(1)

  let index = 0
  while (index < n - 2) {
    const delItem = queue.dequeue()
    queue.enqueue(delItem + queue.head())
    index++
  }

  return queue.tail()
}

console.log(fibonacci(1), fibonacci(2), fibonacci(3), fibonacci(4), fibonacci(5), fibonacci(6))
